import { PPTSIGN } from "./api";
import Axios from "../utils/axios/Axios";

// 二维码签到
export const qRCodeSign = async (enc: string, name: string, fid: string, uid: string, aid: string | number, uf: string, _d: string, vc3: string) => {
  const res = await Axios.request({
    url: PPTSIGN.URL + `?enc=${enc}&name=${encodeURI(name)}&activeId=${aid}&uid=${uid}&clientip=&useragent=&latitude=-1&longitude=-1&fid=${fid}&appType=15`,
    headers: {
      'Cookie': `uf=${uf}; _d=${_d}; UID=${uid}; vc3=${vc3};`
    }
  })
  const data = res.data
  if (data === 'success') {
    return `[二维码]签到成功`
  }
  return data as string;
}
// 位置签到
export const locationSign = async (uf: string, _d: string, vc3: string, name: string, address: string, activeId: string | number, uid: string, lat: string, lon: string, fid: string): Promise<string> => {
  const res = await Axios.request({
    url: PPTSIGN.URL + `?name=${name}&address=${address}&activeId=${activeId}&uid=${uid}&clientip=&latitude=${lat}&longitude=${lon}&fid=${fid}&appType=15&ifTiJiao=1`,
    method: PPTSIGN.METHOD as any,
    headers: {
      'Cookie': `uf=${uf}; _d=${_d}; UID=${uid}; vc3=${vc3};`
    }
  })
  const data = res.data
  if (data === 'success') {
    return `[位置]签到成功`
  }
  return data as string;
}
// 手势签到 签到码签到
export const generalSign = async (uf: string, _d: string, vc3: string, name: string, activeId: string | number, uid: string, fid: string): Promise<string> => {
  const res = await Axios.request({
    url: PPTSIGN.URL + `?activeId=${activeId}&uid=${uid}&clientip=&latitude=-1&longitude=-1&appType=15&fid=${fid}&name=${encodeURI(name)}`,
    method: PPTSIGN.METHOD as any,
    headers: {
      'Cookie': `uf=${uf}; _d=${_d}; UID=${uid}; vc3=${vc3};`
    }
  })
  const data = res.data
  if (data === 'success') {
    return `[通用(手势,签到码,普通)]签到成功`;
  }
  return data as string;
}
